package com.mall4jcola.cloud.auth.executor.query;

import com.alibaba.cola.dto.SingleResponse;
import com.mall4jcola.cloud.auth.gateway.UserAuthsQueryGateway;
import com.mall4jcola.cloud.auth.model.UserLoginInfo;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import javax.validation.constraints.NotBlank;

/**
 * 查询登录账号信息
 * @author hmxchen
 */
@Component
@AllArgsConstructor
public class SingleLoginInfoQryExe {

    private final UserAuthsQueryGateway userAuthsQueryGateway;

    public SingleResponse<UserLoginInfo> execute(@NotBlank(message = "账号类型不可为空") String identityType, String identifier) {
        return SingleResponse.of(UserLoginInfo.of(userAuthsQueryGateway.getByIdentityTypeAndIdentifier(identityType,identifier)));
    }
}
